$(function () {
    getOrderReturnBack();
});
function getOrderReturnBack(){
    $.getJSON("../order_queryBack.json",function (data) {
        if(data.success==true){
            var messsage;
            $.each(data.orders,function (i,value) {
                if(value.middleMessage==null||value.middleMessage==""){
                    messsage=value.deliverMessage;
                }else {
                    messsage=value.middleMessage;
                }
                $(".table-return-order").append("<tr>" +
                    "<td>"+value.orderNo+"</td>" +
                    "<td>"+value.toName+"</td>" +
                    "<td>"+(messsage==null?"":messsage)+"</td>" +
                    "<td><button class='sureForreturn btn btn-primary btn-primary btn-sm btn-table'>确认</button></td>" +
                    "</tr>");
                $(".sureForreturn").unbind("click");
                $(".sureForreturn").click(function () {
                    var $this = $(this);
                    var orderNo= $(this).parent().parent().find(":eq(0)").text();
                    $.getJSON("../order_confirmBack.json",{orderNo:orderNo},function (data) {
                        if(data.success){
                            $this.parent().parent().remove();
                            // getCounterForReturn();
                            window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.success);
                        } else {
                            window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.error);
                        }
                    });
                });
            })
        }else {

        }
    });
}